<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page contentType="text/html;charset=utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<title>用户注册 - 当当网</title>
		<link href="${pageContext.request.contextPath}/css/login.css" rel="stylesheet" type="text/css" />
		<link href="${pageContext.request.contextPath}/css/page_bottom.css" rel="stylesheet" type="text/css" />
	</head>
	<body>
		<%@include file="../common/head1.jsp"%>

		<div class="login_step">
			注册步骤: 1.填写信息 >
			<span class="red_bold">2.验证邮箱</span> > 3.注册成功
		</div>
		<form action="${pageContext.request.contextPath}/user/regist_ok.do" method="post" onsubmit="return checkForm()">
			<div class="validate_email">
				<h2>
					感谢您注册当当网！现在登录您的注册邮箱完成激活账号!
				</h2>
			</div>
			<div align="center">
				现在将向邮箱${sessionScope.ruser.email}发送验证码<br/><br/>
				请输入邮箱验证码：<input type="text" name="emailCode" onblur="checkVcode()"/>
				<a href="${pageContext.request.contextPath}/user/sendEmail.do" id="emailCode" >获取验证码</a>
				<span id="emailSpan"></span>
				<c:if test="${param.error == -1}">
					<span style="color: red;">验证码错误</span>
				</c:if>
				<br/><br/>
				<input type="submit" value="提交"/>
			</div>

		</form>
		<%@include file="../common/foot1.jsp"%>
	<script type="text/javascript">
		function checkVcode() {
			let code = document.querySelector("input");
			let s = document.querySelector("#emailSpan");
			let reg = /[0-9]{6}/;
			if(reg.test(code.value)){
				s.innerHTML="";
				return true;
			}else{
				s.innerHTML = "请输入正确的验证码";
				s.style.color = "red";
				return false;
			}
		}
		function checkForm(){
			return checkVcode();
		}
	</script>
	</body>
</html>

